package com.ihrm.employee.service.impl;

import com.ihrm.domain.employee.EmployeePositive;
import com.ihrm.employee.mapper.EmployeePositiveMapper;
import com.ihrm.employee.service.api.PositiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class PositiveServiceImpl implements PositiveService {
    @Autowired
    private EmployeePositiveMapper employeePositiveMapper;

    public EmployeePositive findById(String uid, Integer status) {
        EmployeePositive employeePositive = employeePositiveMapper.selectByPrimaryKey(uid);
        if (status != null && employeePositive != null) {
            if (employeePositive.getEstatus() != status) {
                employeePositive = null;
            }
        }
        return employeePositive;
    }

    @Override
    public void insert(EmployeePositive positive) {
        positive.setCreateTime(new Date());
        positive.setEstatus(1);//未执行
        employeePositiveMapper.insertSelective(positive);
    }

    public EmployeePositive findById(String uid) {
        return employeePositiveMapper.selectByPrimaryKey(uid);
    }

    public void update(EmployeePositive employeePositive) {
        employeePositive.setCreateTime(new Date());
        employeePositive.setEstatus(1);//未执行
        employeePositiveMapper.updateByPrimaryKeySelective(employeePositive);
    }
}
